package com.wc.fortnight_blue_bridge.Q240309.F_矩阵X;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/9 20:23
 * @description https://www.lanqiao.cn/problems/17002/learning/?contest_id=174
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int[][] a;
    static long[][] b;
    static int n, m, nn, mm;
    static int N = 1000010;
    static ArrayList<LinkedList<Integer>> maxQs = new ArrayList<>();
    static ArrayList<LinkedList<Integer>> minQs = new ArrayList<>();

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        nn = sc.nextInt();
        mm = sc.nextInt();
        a = new int[n + 10][m + 10];
        b = new long[n + 10][m + 10];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = sc.nextInt();
                // 前缀和
                b[i][j] = b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1] + a[i][j];
            }
        }
        // 每一列的单调队列
        maxQs.add(new LinkedList<>());
        minQs.add(new LinkedList<>());
        for (int i = 1; i <= m; i++) {
            maxQs.add(new LinkedList<>());
            minQs.add(new LinkedList<>());
        }

        // 将前1 ~ nn - 1行加上
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j < nn; j++) {
                addMax(a[j][i], maxQs.get(i));
                addMin(a[j][i], minQs.get(i));
            }
        }

        long res = 0;
        for (int i = 1; i <= n - nn + 1; i++) {
            // 将下一行加上
            for (int j = 1; j <= m; j++) {
                addMax(a[i + nn - 1][j], maxQs.get(j));
                addMin(a[i + nn - 1][j], minQs.get(j));
            }
            // 行的单调栈
            LinkedList<Integer> rowMaxQ = new LinkedList<>();
            LinkedList<Integer> rowMinQ = new LinkedList<>();

            // 将前1 ~ mm - 1 列最小/最小值加上
            for (int j = 1; j < mm; j++) {
                addMax(maxQs.get(j).get(0), rowMaxQ);
                addMin(minQs.get(j).get(0), rowMinQ);
            }

            for (int j = 1; j <= m - mm + 1; j++) {
                // 将最后一列最大最小值加上
                addMax(maxQs.get(j + mm - 1).get(0), rowMaxQ);
                addMin(minQs.get(j + mm - 1).get(0), rowMinQ);

                long g = b[i + nn - 1][j + mm - 1] + b[i - 1][j - 1] - b[i - 1][j + mm - 1] - b[i + nn - 1][j - 1];
                long f = rowMaxQ.get(0) - rowMinQ.get(0);

                res = Math.max(f * g, res);
                // 将前面的一列去掉
                popMax(maxQs.get(j).get(0), rowMaxQ);
                popMin(minQs.get(j).get(0), rowMinQ);
            }

            // 将最前面一行去掉
            for (int j = 1; j <= m; j++) {
                popMax(a[i][j], maxQs.get(j));
                popMin(a[i][j], minQs.get(j));
            }
        }
        out.println(res);
        out.flush();
    }

    static void addMax(int x, LinkedList<Integer> maxQ) {
        while (!maxQ.isEmpty() && x > maxQ.get(maxQ.size() - 1)) {
            maxQ.removeLast();
        }
        maxQ.add(x);
    }

    static void popMax(int x, LinkedList<Integer> maxQ) {
        if (maxQ.get(0) == x) {
            maxQ.removeFirst();
        }
    }

    static void addMin(int x, LinkedList<Integer> minQ) {
        while (!minQ.isEmpty() && x < minQ.get(minQ.size() - 1)) {
            minQ.removeLast();
        }
        minQ.add(x);
    }

    static void popMin(int x, LinkedList<Integer> minQ) {
        if (minQ.get(0) == x) {
            minQ.removeFirst();
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}